/**
 * Created with IntelliJ IDEA.
 * User: duoba
 * Date: 16/2/23
 * Time: 上午11:42
 * To change this template use File | Settings | File Templates.
 */

package com.cake21.uitest.System.Driver;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class ExtendWebDriver {

    /*浏览器驱动*/
    private WebDriver driver = null;

    public WebDriver getDriver() {
        return driver;
    }

    /*构造函数*/
    public ExtendWebDriver(WebDriver driver) {
        this.driver = driver;
    }

    /*根询id属性查找页面元素*/
    public WebElement id(String id) {
        return driver.findElement(By.id(id));
    }

    /*根据name属性查找页面元素*/
    public WebElement name(String name) {
        return driver.findElement(By.id(name));
    }

    public List<WebElement> names(String name) {
        return driver.findElements(By.id(name));
    }

    /*根据tag属性查找页面元素*/
    public WebElement tag(String tag) {
        return driver.findElement(By.tagName(tag));
    }

    public List<WebElement> tags(String tag) {
        return driver.findElements(By.tagName(tag));
    }

    public WebElement classx(String classx) {
        return driver.findElement(By.className(classx));
    }

    /*根据class属性查找页面元素*/
    public List<WebElement> classes(String classx) {
        return driver.findElements(By.className(classx));
    }

    /*根据css选择器查找页面元素*/
    public WebElement css(String selector) {
        return driver.findElement(By.cssSelector(selector));
    }

    public List<WebElement> csses(String selector) {
        return driver.findElements(By.cssSelector(selector));
    }

    /*根据xpath查找页面元素*/
    public WebElement xpath(String xpath) {
        return driver.findElement(By.xpath(xpath));
    }

    public List<WebElement> xpathes(String xpath) {
        return driver.findElements(By.xpath(xpath));
    }

    /*根据超链接文本查找页面元素*/
    public WebElement link(String text) {
        return driver.findElement(By.linkText(text));
    }

    public List<WebElement> links(String text) {
        return driver.findElements(By.linkText(text));
    }

    /*根据部分超链接文本查找页面元素*/
    public WebElement plink(String text) {
        return driver.findElement(By.partialLinkText(text));
    }

    public List<WebElement> plinks(String text) {
        return driver.findElements(By.partialLinkText(text));
    }
}
